import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Login from "../components/Login";
import Appindex from "../components/home/Appindex";
import Home from "../components/Home";
import LibraryIndex from "../components/library/LibraryIndex";

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: '/index',
      component: Appindex,
      //判断是否需要拦截
      meta: {
        requireAuth: true
      }
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      //home页面不需要被访问,仍然可以通过index访问首页
      redirect: '/index',
      children: [
        {
          path: '/index',
          name: 'Appindex',
          component: Appindex,
          //判断是否需要拦截
          meta: {
            requireAuth: true
          }
        },
        {
          path: '/library',
          name: 'library',
          component: LibraryIndex,
          //判断是否需要拦截
          meta: {
            requireAuth: true
          }
        }
      ]
    }
  ]
})
